package com.newcoin.chat.controller;

import com.newcoin.chat.beans.vo.ResultVo;
import com.newcoin.chat.service.CircleOfFriendsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/circleOfFriends")
public class CircleOfFriendsController {

    @Autowired
    private CircleOfFriendsService service;

    /**
     * 发布朋友圈
     *
     * @param userId
     * @param type
     * @param state
     * @param whoCanSee
     * @param content
     * @param file
     * @param seeOrNotSeeUserId
     * @return
     */
    @PostMapping(value = "/sendCircleOfFriend")
    public ResultVo<String> sendCircleOfFriend(Long userId, String type, Integer state, Integer whoCanSee, String content, String file, String seeOrNotSeeUserId) {
        try {
            return service.sendCircleOfFriend(userId, type, state, whoCanSee, content, file, seeOrNotSeeUserId);
        } catch (Exception e) {
            e.printStackTrace();
            ResultVo<String> resultVo = new ResultVo<>();
            resultVo.setMsg("系统错误");
            resultVo.setStatus(500);
            return resultVo;
        }
    }

    /**
     * 删除朋友圈内容
     *
     * @param userId
     * @param circleFriendsId
     * @return
     */
    @PostMapping(value = "/deleteCircleOfFriend")
    public ResultVo deleteCircleOfFriend(Long userId, Long circleFriendsId) {
        try {
            return service.deleteCircleOfFriend(userId, circleFriendsId);
        } catch (Exception e) {
            ResultVo resultVo = new ResultVo();
            resultVo.setStatus(500);
            resultVo.setMsg("系统错误");
            return resultVo;
        }
    }

    /**
     * 点赞
     *
     * @param likeUserId
     * @param circleFriendsId
     * @return
     */
    @PostMapping(value = "/circleOfFriendLike")
    public ResultVo circleOfFriendLike(Long likeUserId, Long circleFriendsId) {
        try {
            return service.circleOfFriendLike(likeUserId, circleFriendsId);
        } catch (Exception e) {
            ResultVo resultVo = new ResultVo();
            resultVo.setStatus(500);
            resultVo.setMsg("系统出错");
            return resultVo;
        }
    }

    /**
     * 评论
     * @param commentUserId
     * @param circleFriendsId
     * @param content
     * @return
     */
    @PostMapping(value = "/circleOfFriendComment")
    public ResultVo circleOfFriendComment(Long commentUserId, Long circleFriendsId, String content) {
        try {
            return service.circleOfFriendComment(commentUserId, circleFriendsId, content);
        } catch (Exception e) {
            ResultVo resultVo = new ResultVo();
            resultVo.setStatus(500);
            resultVo.setMsg("系统出错");
            return resultVo;
        }
    }

}
